package com.xykj.enterprise.wechat.ext.service.contacts;

import com.xykj.enterprise.wechat.bean.ext.BaseResp;
import com.xykj.enterprise.wechat.ext.service.QYWXHttpCommUtil;
import com.xykj.enterprise.wechat.bean.ext.contacts.tag.AddTagUserVo;
import com.xykj.enterprise.wechat.bean.ext.contacts.tag.AddTagVo;
import com.xykj.enterprise.wechat.bean.ext.contacts.tag.DeleteTagUserVo;
import com.xykj.enterprise.wechat.bean.ext.contacts.tag.GetTagUserVo;
import com.xykj.enterprise.wechat.bean.ext.contacts.tag.TagListVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
@Slf4j
public class ContactsTagServiceImpl implements ContactsTagService {

    @Override
    public AddTagVo createTag(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("tag/create", params, AddTagVo.class);
    }

    @Override
    public BaseResp updateTag(String accessToken, Integer tagid, String tagname) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("tagid", tagid);
        params.put("tagname", tagname);
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("tag/update", params, BaseResp.class);
    }

    @Override
    public BaseResp deleteTag(String accessToken, Integer tagid) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.get("tag/delete", params, BaseResp.class);
    }

    @Override
    public GetTagUserVo getTagUser(String accessToken, Integer tagid) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("access_token", accessToken);
        params.put("tagid", tagid);
        return QYWXHttpCommUtil.get("tag/get", params, GetTagUserVo.class);
    }

    @Override
    public AddTagUserVo addTagUser(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("tag/addtagusers", params, AddTagUserVo.class);
    }

    @Override
    public DeleteTagUserVo deleteTagUser(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("tag/deltagusers", params, DeleteTagUserVo.class);
    }

    @Override
    public TagListVo tagList(String accessToken) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("tag/list", params, TagListVo.class);
    }
}
